{include file="public/header" /}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">任务管理</a>
        <a href="">生产审核</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="{:url()}" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>

<div class="x-body" >
    <xblock>
        <a class="layui-btn"  target="_blank" href="{:url()}"><i class="iconfont">&#xe718;</i> 框架页面</a>
        <span class="x-right" style="line-height:40px">共{$productLogCount}条 · 共{$productLogCount/25|getInt}页</span>
        {if $tag == 0}
        <button class="layui-btn layui-btn-sm" onclick="sheheAll()">批量审核</button>
        {else}
        <button class="layui-btn layui-btn-sm" onclick="quxiaoAll()">批量取消</button>
        {/if}
    </xblock>
    <div class="container-wrap">
        <div class="box-1">
            <table class="layui-table">
                <thead>
                <tr>
                    <th width="20px;">
                        <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
                    </th>
                    <!--<th>-->
                    <!--<div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>-->
                    <!--</th>-->
                    <th>
                        {if $tag == 0}
                        <a href="{:url('index/ProductionRecords/toExmine',['tag'=>1])}"><button class="layui-btn layui-btn-sm">已审</button></a>
                        {else}
                        <a href="{:url('index/ProductionRecords/toExmine',['tag'=>0])}"><button class="layui-btn layui-btn-sm">未审</button></a>
                        {/if}
                    </th>
                    <!--<th>生产记录编号</th>-->
                    <th>工序</th>
                    <!--<th>检验记录</th>-->
                    <!--<th>品管</th>-->
                    <th>类型</th>
                    <th>操作者</th>
                    <th>数量</th>
                    <th>完成日期</th>
                    <th>设备</th>
                    <!--<th>任务编号</th>-->
                    <!--<th>外协费用</th>-->
                    <!--<th>外协单位</th>-->
                    <th>合格数</th>
                    <th>质量等级</th>
                    <!--<th>检验员</th>-->
                    <!--<th>互检人</th>-->
                    <!--<th>品质放行</th>-->
                    <th>管理审核</th>
                    <th>任务编号</th>
                    <th>内图编号</th>
                    <th>外图编号</th>
                    <th>图纸名称</th>
                    <th>批量</th>
                    <th>工艺</th>
                    <th>备注</th>
                    <th>创建日期</th>
                    <th>创建人</th>
                    <th>修改日期</th>
                    <th>修改人</th>
                </tr>
                </thead>
                <tbody>
                {volist name="$productLog" id="list"}
                <tr>
                    <td>
                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$list.log_id}'><i class="layui-icon">&#xe605;</i></div>
                    </td>
                    <td class="td-manage">
                        <!--<a title="修改" onclick="x_admin_show('修改 <span class=\'layui-badge layui-bg-blue\'>{$list.log_id}</span> 生产记录','{:url(\'index/ProductionRecords/edit\',[\'id\'=>$list.log_id,\'drawing\'=>$drawing,\'task_id\'=>$task_id])}')" href="javascript:;"><i style="color: green" class="layui-icon"></i></a>-->
                        <!--<a title="删除" onclick="delete_(this,'{$list.log_id}')" href="javascript:void(0);" >-->
                            <!--<i  style="color:red;" class="layui-icon"></i>-->
                        <!--</a>-->
                    </td>
                    <td {$list.fulfill==0?'':'style="background:greenyellow"'}>{:substr($list['log_id'],-2)}</td>
                    <!--<td>-->
                        <!--<?php $ifczs = ifCz($list['process_id']);?>-->
                        <!--{if $ifczs}-->
                        <!--<a style="color: green" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$list.log_id}</span> 的检验记录','{:url(\'index/TestRecord/viewIndex\',[\'task_id\'=>$list.log_id])}')" href="javascript:;">记录</a>-->
                        <!--{else}-->
                        <!--<a style="color: green" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$list.log_id}</span> 的检验记录','{:url(\'index/TestRecord/viewIndex\',[\'task_id\'=>$list.log_id])}')" href="javascript:;">无</a>-->
                        <!--{/if}-->
                    <!--</td>-->
                    <!--<td>-->
                        <!--<?php $ifczs = ifPk($list['process_id']);?>-->
                        <!--{if $ifczs}-->
                        <!--<a style="color: green" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$list.log_id}</span> 的品管','{:url(\'index/TestRecord/qualityShow\',[\'task_id\'=>$list.log_id])}',500)" href="javascript:;">品管</a>-->
                        <!--{else}-->
                        <!--<a style="color: green" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$list.log_id}</span> 的品管','{:url(\'index/TestRecord/qualityShow\',[\'task_id\'=>$list.log_id])}',500)" href="javascript:;">无</a>-->
                        <!--{/if}-->
                    <!--</td>-->
                    <td>{$list.process_id|getGyType}</td>
                    <td>{$list.hr_id|getUserName}</td>
                    <td>{$list.complete_qty}</td>
                    <td>{$list.complete_date}</td>
                    <td>{$list.eqpmt_id}</td>
                    <!--<td>{$list.task_id}</td>-->
                    <!--<td>{$list.cost}</td>-->
                    <!--<td>{$list.costUnit}</td>-->
                    <td>{$list.product_qty}</td>
                    <td>{$list.quality_grade}</td>
                    <!-- -->
                    <!--<td>-->
                        <!--{if $list.other_checker==""}-->
                        <!--<a title="互检签字" onclick="sign_('{$list.log_id}','other_checker_date','other_checker')" href="javascript:void(0);" >-->
                            <!--未签字-->
                        <!--</a>-->
                        <!--{else}-->
                        <!--<a title="取消互检签字" onclick="signDown_('{$list.log_id}','other_checker_date','other_checker')" href="javascript:void(0);" >-->
                            <!--{$list.other_checker} {$list.other_checker_date}-->
                        <!--</a>-->
                        <!--{/if}-->
                    <!--</td>-->
                    <!--<td>-->
                        <!--{if $list.manege_name==""}-->
                        <!--<a title="品质放行" onclick="sign_('{$list.log_id}','manege_date','manege_name')" href="javascript:void(0);" >-->
                            <!--未签字-->
                        <!--</a>-->
                        <!--{else}-->
                        <!--<a title="取消品质放行" onclick="signDown_('{$list.log_id}','manege_date','manege_name')" href="javascript:void(0);" >-->
                            <!--{$list.manege_name} : {$list.manege_date}-->
                        <!--</a>-->
                        <!--{/if}-->
                    <!--</td>-->
                    <td>
                        {$list.if_audit}
                        {if $list.if_audit == '未审'}
                              <button class="layui-btn layui-btn-sm" onclick="shenhe('{$list.log_id}')">审核</button>
                        {else}
                             <button class="layui-btn layui-btn-sm"  onclick="quxiao('{$list.log_id}')">取消</button>
                        {/if}
                    </td>
                    <td><a href="javascript:;" style="color: #0000cc" onclick="x_admin_show('任务','{:url(\'index/CurrentTask/pinTsk\',[\'id\'=>$list.task_id])}')">{$list.task_id}</a></td>
                    <td>
                        <?php $blueprintInfoList = productGetDrawingEetialCode($list['task_id']); ?>
                        {$blueprintInfoList.drawing_internal_id}
                    </td>
                    <td> {$blueprintInfoList.drawing_externa_id}</td>
                    <td>{$blueprintInfoList.drawing_name}</td>
                    <td>
                        {if $blueprintInfoList.if_batch == 0}
                        否
                        {else}
                        是
                        {/if}
                    </td>
                    <td class="td-manage">
                        {if $blueprintInfoList.files_state==0||$blueprintInfoList.drawing_externa_id==""||!widget('Widget/drawing_check',['drawing_id'=>$blueprintInfoList.drawing_externa_id])}<!-- 不继承或者外图继承无效 -->


                        <a title="图纸" onclick="x_admin_show('图纸明细 <span class=\'layui-badge layui-bg-blue\'>{$blueprintInfoList.drawing_detail_id}</span> 的图纸文件',
          '{:url(\'index/blueprint/is_DrawingFiles\',[\'id\'=>$blueprintInfoList.id,\'key\'=>\'wai\',\'drawing_num\'=>$blueprintInfoList.drawing_detail_id])}')" href="javascript:;">
                            <span class="layui-badge layui-bg-{:widget('Widget/files_check',['id'=>$blueprintInfoList.id,'tip'=>'abroad'])}">图</span></a>

                        {elseif $blueprintInfoList.files_state==1} <!-- 继承 -->
                        <a title="图纸" onclick="x_admin_show('图纸明细 <span class=\'layui-badge layui-bg-blue\'>{$blueprintInfoList.drawing_detail_id}</span> 的图纸文件',
          '{:url(\'index/blueprint/is_outDrawing\',[\'id\'=>$blueprintInfoList.drawing_externa_id])}')" href="javascript:;"><span class="layui-badge layui-bg-orange">图</span></a>
                        {/if}

                        <a title="模型" onclick="x_admin_show('图纸明细 <span class=\'layui-badge layui-bg-blue\'>{$blueprintInfoList.drawing_detail_id}</span> 的3d模型文件',
          '{:url(\'index/blueprint/is_DrawingFiles\',[\'id\'=>$blueprintInfoList.id,\'key\'=>\'nei\',\'drawing_num\'=>$blueprintInfoList.drawing_detail_id])}')" href="javascript:;"><span class="layui-badge layui-bg-{:widget('Widget/files_check',['id'=>$blueprintInfoList.id,'tip'=>'within'])}">3D</span></a>
                        <a title="程序单" onclick="x_admin_show('图纸明细 <span class=\'layui-badge layui-bg-blue\'>{$blueprintInfoList.drawing_detail_id}</span> 的程序单文件',
          '{:url(\'index/blueprint/is_DrawingFiles\',[\'id\'=>$blueprintInfoList.id,\'key\'=>\'cheng\',\'drawing_num\'=>$blueprintInfoList.drawing_detail_id])}')" href="javascript:;"><span class="layui-badge layui-bg-{:widget('Widget/files_check',['id'=>$blueprintInfoList.id,'tip'=>'engineering'])}">程</span></a>
                        {if $blueprintInfoList.is_gongxu !=0}
                        <a title="工"  href="javascript:;" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$blueprintInfoList.drawing_detail_id}</span> 的工艺信息','{:url(\'index/blueprint/process\',[\'drawing_detail_id\'=>$blueprintInfoList.drawing_detail_id])}')" ><span class="layui-badge layui-bg-green">工</span></a>
                        {else}

                        <a title="工"  href="javascript:;" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$blueprintInfoList.drawing_detail_id}</span> 的工艺信息','{:url(\'index/blueprint/process\',[\'drawing_detail_id\'=>$blueprintInfoList.drawing_detail_id])}')" ><span  class="layui-badge layui-bg-blue">工</span></a>
                        {/if}
                    </td>
                    <td>{$list.remark}</td>
                    <td>{$list.create_time}</td>
                    <td>{$list.create_name}</td>
                    <td>{$list.update_time}</td>
                    <td>{$list.update_name}</td>
                </tr>
                {/volist}
                </tbody>
            </table>
        </div>
    </div>
    <!--___________________________________-->
    <div class="page">
        {$productLog|raw}
    </div>
    <script>
        function shenhe(id) {
            layer.confirm('确定要通过审核吗？',function(index){
                var url = "{:url('index/ProductionRecords/shenhe')}";
                var postData ={"id":id};
                $.post(url,postData,function (result) {
                    if(result === 1 ){
                        location.reload();
                        layer.msg('审核通过!',{icon:1,time:1000});
                    }else {
                        location.reload();
                        layer.msg("操作失败", {icon:5,time:1000});
                    }
                },"json");
            });
        }
        function quxiao(id) {
            layer.confirm('确定要取消审核吗？',function(index){
                var url = "{:url('index/ProductionRecords/xuxiao')}";
                var postData ={"id":id};
                $.post(url,postData,function (result) {
                    if(result === 1 ){
                        location.reload();
                        layer.msg('审核通过!',{icon:1,time:1000});
                    }else {
                        location.reload();
                        layer.msg("操作失败", {icon:5,time:1000});
                    }
                },"json");
            });
        }
        /*删除*/
        function delete_(obj,id){
            layer.confirm('确认要删除吗？',function(index){
                var url = "{:url('index/ProductionRecords/delete')}";
                var postData ={"id":id};
                $.post(url,postData,function (result) {
                    if(result === 1 ){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else {
                        layer.msg("删除失败", {icon:5,time:1000});
                    }
                },"json");
            });
        }

        //签字
        function sign_(where,dateKey,nameKey){
            layer.confirm("确定要签名吗？<br>姓名:{$Think.session.user.user_name}<br>日期:{:date('Y-m-d')}",function(index){
                var url = "{:url('index/ProductionRecords/sign')}";
                var postData ={"where":where,"dateKey":dateKey,"nameKey":nameKey};
                $.post(url,postData,function (result) {
                    if(result){
                        location.reload();
                        layer.msg('已签名!',{icon:1,time:1000});
                    }else {
                        location.reload();
                        layer.alert("签名失败", {icon: 5});
                    }
                },"json");
            });
        }
        //签字
        function signDown_(where,dateKey,nameKey){
            layer.confirm('确定取消签名吗？',function(index){
                var url = "{:url('index/ProductionRecords/signDown')}";
                var postData ={"where":where,"dateKey":dateKey,"nameKey":nameKey};
                $.post(url,postData,function (result) {
                    if(result){
                        location.reload();
                        layer.msg('已取消签名!',{icon:1,time:1000});
                    }else {
                        location.reload();
                        layer.alert("取消签名失败", {icon: 5});
                    }
                },"json");
            });
        }
        $(function () {
            $("#addLog").click(function () {
                layer.msg('正在加载中...', {time:500});
            })
        });
        function quxiaoAll() {
            var data = tableCheck.getData();
            if (data == ''){
                layer.msg('请选择需要取消审核的生产记录');
                return false;
            }
            layer.confirm('确定将所有的生产记录都取消审核？',function(index){
                var url = "{:url('index/ProductionRecords/quxiaoAll')}";
                var postData ={"data":data};
                $.post(url,postData,function (result) {
                    if(result === 1 ){
                        location.reload();
                        layer.msg('取消审核成功!',{icon:1,time:1000});
                    }else {
                        location.reload();
                        layer.msg("操作失败", {icon:5,time:1000});
                    }
                },"json");
            });

        }
        function sheheAll() {
            var data = tableCheck.getData();
            if (data == ''){
                layer.msg('请选择需要审核的生产记录');
                return false;
            }
            layer.confirm('确定将所有的生产记录都审核？',function(index){
                var url = "{:url('index/ProductionRecords/sheheAll')}";
                var postData ={"data":data};
                $.post(url,postData,function (result) {
                    if(result === 1 ){
                        location.reload();
                        layer.msg('审核成功!',{icon:1,time:1000});
                    }else {
                        location.reload();
                        layer.msg("操作失败", {icon:5,time:1000});
                    }
                },"json");
            });

        }
    </script>
</div>

</body>
</html>